// pages/myMenu/myMenu.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    deskId: '',
    deskCaption: '',
    orderMenuList:[],
    sun:'',
    //备注
    values:'',
    menuMemoList:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.setData({
      deskId:options.deskId,
      deskCaption: options.deskCaption,
      values:options.values
    })
    this.getMenuList()
    this.getMemo()
    this.getMenuMemoList()
    console.log('values',options.values)
  },
  //获取菜品
  getMenuList(){
    wx.request({
      url: 'http://www.szyzit.com:8080/CateringSystem1.0/recruitment/catering/qryOrderMenuList.do?method=login',
      method:'POST',
      header:{'Content-type': 'application/x-www-form-urlencoded'},
      data:{
        deskId:this.data.deskId,
        status: '1,2,3,4,5,6,7',
        listAll: 1
      },
      success:(res)=>{
        let num1=0;
        res.data.responseBody.orderMenuList.map(item=>{
          num1=num1+item.promotionPrice
          return num1
        })
        this.setData({
          orderMenuList:res.data.responseBody.orderMenuList,
          sun:num1
        })
      }
    })
  },
  //获取备注
  getMemo(){
    wx.request({
      url: 'http://www.szyzit.com:8080/CateringSystem1.0/recruitment/catering/addMenuMemo.do?method=login',
      method:'POST',
      header:{'Content-type': 'application/x-www-form-urlencoded'},
      data:{
        deskId:this.data.deskId,
        menuId:'',
        menuItemSpecialRequestDesc:this.data.values
      },
      success:(res)=>{
        console.log('成功')
      },
      fail:(res)=>{
        wx.showToast({
          title: '请求失败',
        })
      }
    })
  },
  getMenuMemoList(){
    wx.request({
      url: 'http://www.szyzit.com:8080/CateringSystem1.0/recruitment/catering/qryMenuMemoList.do?method=login',
      method:'POST',
      header:{'Content-type': 'application/x-www-form-urlencoded'},
      data:{
        deskId:this.data.deskId,
        menuId:''
      },
      success:(res)=>{
        this.setData({
          menuMemoList:res.data.responseBody.menuMemoList
        })
      },
      fail:(res)=>{
        wx.showToast({
          title: '请求失败',
        })
      }
    })
  },
  //返回上一页
  toback() {
    wx.navigateBack({
      delta: 1
    })
  },
})